<?php

class SubFactory extends AbstractDecoratorFactory
{
	/**
	 * @var Mapper
	 */
	private $_SubMapper;
	
	public function __construct(Factory $Factory, Mapper $SubMapper)
	{
		parent::__construct($Factory);
		$this->_SubMapper = $SubMapper;
	}
	
	/**
	 * @return AutoUpdater
	 * @ return Mapper
	 */
	public function getSubMapper()
	{
		return $this->_SubMapper;
	}
	
	public function create(array $data)
	{
		$Phlame = $this->_Factory->create($data);
        $binder = constant(get_class($this->getSubMapper()).'::SUB_BINDER');
		$Phlame->addSubs($this->getSubMapper()->selectByIDs($this->getMapper()->getIDs, $binder)->getAsGroup->getMember($Phlame->getID()));
		return $Phlame;
	}
}
